package exception;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wwy
 * Date: 2024-11-21
 * Time: 13:07
 */

public  class Login {
        private String userName;
        private String passWord;

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public String getPassWord() {
            return passWord;
        }

        public void setPassWord(String passWord) {
            this.passWord = passWord;
        }

        public  void logInfo(String userName, String passWord) throws UserNameException,
                PasswordException {
            if(!this.userName.equals(userName)) {
                throw new UserNameException("用户名错误异常.....");
            }

            if(!this.passWord.equals(passWord)) {
                throw new PasswordException("密码错误异常.....");
            }
            System.out.println("登录成功！");

        }
        public static void main(String[] args) {
            Login login = new Login();
            login.setUserName("abc");
            login.setPassWord("123");
            try {
                login.logInfo("abc6", "1Q23");
            }catch (UserNameException e) {
                e.printStackTrace();
            }catch (PasswordException e) {
                e.printStackTrace();
            }finally {

            }
        }
}
